﻿using System;
using System.Windows.Controls;
using Gencode.VECore;
using System.Collections.Generic;

namespace Gencode.VECUtil
{
    public class CanvasManager : Viewbox
    {
        List<CanvasDocument> _documentList;

        CanvasDocument _curentDocument;
        public CanvasDocument CurentDocument
        {
            get
            {
                return _curentDocument;
            }
            private set
            {
                _curentDocument = value;
            }
        }

        public CanvasManager()
        {
            _documentList = new List<CanvasDocument>();
        }

        public void Dispose()
        {
            if (CurentDocument != null)
            {
                CurentDocument.Dispose();
                _documentList.Remove(CurentDocument);

                CurentDocument = null;

                if (_documentList.Count > 0)
                    CurentDocument = _documentList[_documentList.Count - 1];
            }
        }

        public void AddCanvas(double width, double height)
        {
            _documentList.Add(new CanvasDocument
            {
                Width = width,
                Height = height
            });

            CurentDocument = _documentList[_documentList.Count - 1];
            this.Child = CurentDocument;
        }
    }
}
